In [1]:
from konfoo import Index, Byteorder, Scaled, Scaled8, Scaled16, Scaled24, Scaled32, Scaled64
Item type of the field
class.
In [2]:
Scaled.item_type
Out[2]:
Checks if the field
class is a bit
field.
In [3]:
Scaled.is_bit()
Out[3]:
Checks if the field
class is a boolean
field.
In [4]:
Scaled.is_bool()
Out[4]:
Checks if the field
class is a decimal
number field.
In [5]:
Scaled.is_decimal()
Out[5]:
Checks if the field
class is a floating point
number field.
In [6]:
Scaled.is_float()
Out[6]:
Checks if the field
class is a pointer
field.
In [7]:
Scaled.is_pointer()
Out[7]:
Checks if the field
class is a stream
field.
In [8]:
Scaled.is_stream()
Out[8]:
Checks if the field
class is a string
field.
In [9]:
Scaled.is_string()
Out[9]:
In [10]:
scaled = Scaled(scale=100.0, bit_size=32, align_to=None, byte_order='auto')
In [11]:
scaled = Scaled(100.0, 32)
In [12]:
scaled
Out[12]:
In [13]:
str(scaled)
Out[13]:
In [14]:
repr(scaled)
Out[14]:
In [15]:
scaled.name
Out[15]:
In [16]:
scaled.index
Out[16]:
Byte index
of the field
within the byte stream
.
In [17]:
scaled.index.byte
Out[17]:
Bit offset relative to the byte index
of the field
within the byte stream
.
In [18]:
scaled.index.bit
Out[18]:
Absolute address of the field
within the data source
.
In [19]:
scaled.index.address
Out[19]:
Base address of the byte stream
within the data source
.
In [20]:
scaled.index.base_address
Out[20]:
Indexes the field
and returns the index
after the field
.
In [21]:
scaled.index_field(index=Index())
Out[21]:
In [22]:
scaled.alignment
Out[22]:
Byte size of the field group
which the field
is aligned to.
In [23]:
scaled.alignment.byte_size
Out[23]:
Bit offset of the field
within its aligned field group
.
In [24]:
scaled.alignment.bit_offset
Out[24]:
In [25]:
scaled.bit_size
Out[25]:
In [26]:
scaled.byte_order
Out[26]:
In [27]:
scaled.byte_order.value
Out[27]:
In [28]:
scaled.byte_order.name
Out[28]:
In [29]:
scaled.byte_order = 'auto'
In [30]:
scaled.byte_order = Byteorder.auto
Scaling factor of the field
value.
In [31]:
scaled.scale
Out[31]:
Base value for the scale
factor of the field
value.
In [32]:
scaled.scaling_base()
Out[32]:
In [33]:
hex(int(scaled.scaling_base()))
Out[33]:
Checks if the decimal field
is signed or unsigned.
In [34]:
scaled.signed
Out[34]:
Maximal decimal field
value.
In [35]:
scaled.max()
Out[35]:
Minimal decimal field
value.
In [36]:
scaled.min()
Out[36]:
Returns the scaled field
value as an floating point number.
In [37]:
scaled.value
Out[37]:
Returns the decimal field
value aligned to its field group
as a number of bytes.
In [38]:
bytes(scaled)
Out[38]:
In [39]:
bytes(scaled).hex()
Out[39]:
Returns the decimal field
value as an integer number.
In [40]:
int(scaled)
Out[40]:
Returns the decimal field
value as an floating point number.
In [41]:
float(scaled)
Out[41]:
Returns the decimal field
value as a lowercase hexadecimal string prefixed with 0x
.
In [42]:
hex(scaled)
Out[42]:
Returns the decimal field
value as a binary string prefixed with 0b
.
In [43]:
bin(scaled)
Out[43]:
Returns the decimal field
value as an octal string prefixed with 0o
.
In [44]:
oct(scaled)
Out[44]:
Returns the decimal field
value as a boolean value.
In [45]:
bool(scaled)
Out[45]:
Returns the decimal field
value as a signed integer number.
In [46]:
scaled.as_signed()
Out[46]:
Returns the decimal field
value as an unsigned integer number.
In [47]:
scaled.as_unsigned()
Out[47]:
Returns the meatadata
of the field
as an ordered dictionary.
In [48]:
scaled.describe()
Out[48]:
In [49]:
scaled.deserialize(bytes.fromhex('01000000'), byte_order='little')
Out[49]:
In [50]:
scaled.value
Out[50]:
In [51]:
bytes(scaled)
Out[51]:
In [52]:
bytes(scaled).hex()
Out[52]:
In [53]:
int(scaled)
Out[53]:
In [54]:
float(scaled)
Out[54]:
In [55]:
hex(scaled)
Out[55]:
In [56]:
bin(scaled)
Out[56]:
In [57]:
oct(scaled)
Out[57]:
In [58]:
bool(scaled)
Out[58]:
In [59]:
buffer = bytearray()
In [60]:
scaled.value = 1
In [61]:
scaled.value = 1.0
In [62]:
scaled.value = 0x1
In [63]:
scaled.value = 0b1
In [64]:
scaled.value = 0o1
In [65]:
scaled.value = True
In [66]:
scaled.value = 1.0
In [67]:
scaled.serialize(buffer, byte_order='little')
Out[67]:
In [68]:
buffer.hex()
Out[68]:
In [69]:
bytes(scaled).hex()
Out[69]:
In [ ]: